package com.lr.springbootmybatisplusdemo.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.lr.springbootmybatisplusdemo.dao.MallOrderDao;
import com.lr.springbootmybatisplusdemo.dao.MallUserDao;
import com.lr.springbootmybatisplusdemo.dto.MallUserAndOrderDTO;
import com.lr.springbootmybatisplusdemo.entity.MallOrder;
import com.lr.springbootmybatisplusdemo.entity.MallUser;
import com.lr.springbootmybatisplusdemo.service.MallOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 订单表(MallOrder)表服务实现类
 *
 * @author lr
 * @since 2023-03-13 10:39:24
 */
@Service("mallOrderService")
public class MallOrderServiceImpl extends ServiceImpl<MallOrderDao, MallOrder> implements MallOrderService {
    @Resource
    MallOrderDao orderDao;
    @Resource
    MallUserDao userDao;

    public IPage<MallUserAndOrderDTO> joinQueryPage() {
        return orderDao.selectJoinPage(new Page<>(), MallUserAndOrderDTO.class,
                new MPJLambdaWrapper<MallOrder>()
                        .selectAll(MallOrder.class)
                        .selectAll(MallUser.class)
                        .innerJoin(MallUser.class, MallUser::getUserId, MallOrder::getUserId));


    }

    public IPage<MallUserAndOrderDTO> joinQueryPage2() {
        return userDao.selectJoinPage(new Page<>(), MallUserAndOrderDTO.class,
                new MPJLambdaWrapper<MallUser>()
                        .selectAll(MallUser.class)
                        .selectAll(MallOrder.class)
                        .leftJoin(MallOrder.class, MallOrder::getUserId, MallUser::getUserId));


    }
}